package com.example.user.service;


import com.example.user.common.Result;
import com.example.user.entity.Product;
import com.example.user.mapper.FavoriteMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FavoriteService {


    @Autowired
    private FavoriteMapper favoriteMapper;
    public List<Product> selectPage(Integer userId) {
        List<Product> productList= favoriteMapper.selectByUserId(userId);
        return productList;
    }

    public Result cancelCollection(Integer productId) {
       int count= favoriteMapper.cancelCollectionByProductId(productId);
       if(count==0)
       {
           return  Result.error("400","取消收藏失败");
       }
       return Result.success("取消收藏成功");

    }
}
